package com.xdf.whiteaccount.service;

import java.util.List;
import java.util.Optional;
import com.xdf.whiteaccount.entity.FabBaseProductCategory;
import com.xdf.whiteaccount.utils.Example;
import com.xdf.whiteaccount.utils.BusinessException;

/**
 * @Description : 服务层接口，注意自定义代码写在最后，不要插在中间
 * @Author : chanchaw
 * @Date : 2023-8-21 16:58:36
 */
public interface FabBaseProductCategoryService {
    FabBaseProductCategory insert(FabBaseProductCategory record);
    FabBaseProductCategory insertSelective(FabBaseProductCategory record);
    List<FabBaseProductCategory> multiInsert(List<FabBaseProductCategory> list);
    int updateByPrimaryKey(FabBaseProductCategory record);
    int updateByPrimaryKeySelective(FabBaseProductCategory record);
    // 根据主键删除
    int deleteByPrimaryKey(Integer iid);
    // 根据主键查询
    FabBaseProductCategory selectByPrimaryKey(Integer iid);
    List<FabBaseProductCategory> selectAll();
    FabBaseProductCategory save(FabBaseProductCategory record);
    List<FabBaseProductCategory> multiSave(List<FabBaseProductCategory> list);
    FabBaseProductCategory selectBySid(String sid);
    Boolean exists(String sid);
    //================= 下面是默认方法 ==================
    default void checkEntityNotNull(FabBaseProductCategory record){// 返回true表示合法，可继续
        if(record == null) throw new BusinessException("无法保存空数据！");
    }

    default void checkSidNotEmpty(FabBaseProductCategory record){// 返回true表示合法，可继续
        checkEntityNotNull(record);
        String sid = Optional.ofNullable(record.getSid()).orElse("");
        if(sid.length() == 0) throw new BusinessException("编号不可为空！");
    }

    default FabBaseProductCategory fullFill(FabBaseProductCategory record){
        return record;
    }

    default void doBeforeInsert(FabBaseProductCategory record){}
    default void doAfterInsert(FabBaseProductCategory record){}
    List<FabBaseProductCategory> selectByExample(Example<FabBaseProductCategory> example);
    default void check4Insert(FabBaseProductCategory record){
        checkSidNotEmpty(record);
        if(exists(record.getSid())) throw new BusinessException("编号" + record.getSid() + "已经存在，请更换后再次保存！");
    }
    //=================以上是自动生成的代码，自定义代码请写在下面==================
}